package A1_二叉树;

public class LC_222完全二叉树的节点个数 {
    public static class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode(){}
        TreeNode(int val){
            this.val=val;
        }
        TreeNode(int val, TreeNode left, TreeNode right){
            this.val=val;
            this.left=left;
            this.right=right;
        }
    }
    public int countNodes(TreeNode root) {
        if (root == null) {
            return 0;
        }
        int nums=countNodes(root.left) + countNodes(root.right) + 1;
        return nums;
    }
}
